package com.liveneo.adapter.outinterface.web.platform;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.liveneo.adapter.base.support.LogUtils;
import com.liveneo.adapter.mobile.util.PropertyConfigurer;
import com.liveneo.adapter.outinterface.msg.AppMessage;
import com.liveneo.adapter.outinterface.util.DBTableUtil;
import com.liveneo.adapter.outinterface.util.Encryption;
import com.liveneo.adapter.outinterface.util.HttpRequestUtil;
import com.liveneo.adapter.outinterface.util.JsonUtils;
import com.liveneo.adapter.outinterface.util.Message;
import com.liveneo.adapter.outinterface.util.ResultInfo;
import com.liveneo.adapter.outinterface.util.SpringConfigTool;
import com.liveneo.adapter.outinterface.util.StringUtil;
import com.liveneo.adapter.outinterface.util.UUIDUtils;
import com.liveneo.adapter.outinterface.web.platform.request.BaseResponse;
import com.liveneo.adapter.outinterface.web.platform.request.ChangeTaskStatus;
import com.liveneo.adapter.outinterface.web.platform.request.CliamRequest;
import com.liveneo.adapter.outinterface.web.platform.request.CliamUploadDto;
import com.liveneo.adapter.outinterface.web.platform.request.MessageRequest;
import com.liveneo.adapter.outinterface.web.platform.request.RequestHead;
import com.liveneo.adapter.outinterface.web.platform.request.ResponseHead;
import com.liveneo.adapter.outinterface.web.platform.request.TaskStatusRequest;
import com.liveneo.adapter.outinterface.web.platform.request.dto.ClaimCollectTask;
import com.liveneo.adapter.outinterface.web.platform.request.dto.CollectDoc;
import com.liveneo.adapter.outinterface.web.platform.request.dto.NotificationTask;
import com.liveneo.adapter.outinterface.web.platform.request.dto.QueryCaseStatus;
import com.liveneo.adapter.outinterface.web.platform.request.dto.QueryClaim;
import com.liveneo.adapter.outinterface.web.platform.request.dto.QueryVIPService;
import com.liveneo.adapter.outinterface.web.platform.request.dto.SurveyDelegateRequestDto;
import com.liveneo.adapter.outinterface.web.platform.request.dto.VideoCaseEnd;
import com.liveneo.adapter.outinterface.web.platform.response.CaseStatusResponse;
import com.liveneo.adapter.outinterface.web.platform.response.ClaimInfoResponse;
import com.liveneo.adapter.outinterface.web.platform.response.CliamResponse;
import com.liveneo.adapter.outinterface.web.platform.response.FindCaseInfoResponse;
import com.liveneo.adapter.outinterface.web.platform.response.FindEvaluateInfoResponse;
import com.liveneo.adapter.outinterface.web.platform.response.SynBranchInfoResponse;
import com.liveneo.adapter.outinterface.web.platform.response.UploadOCRinfo2JY2GResponse;
import com.liveneo.adapter.outinterface.web.platform.response.UpoadImageResponse;
import com.liveneo.adapter.outinterface.web.platform.response.VIPServiceResponse;
import com.liveneo.adapter.webservice.client.claim.CaseInfo;
import com.liveneo.adapter.webservice.client.claim.ConfirmEvaluateDto;
import com.liveneo.adapter.webservice.client.claim.EvaluateInfoRequestDto;
import com.liveneo.adapter.webservice.client.claim.GgBanklocationsDto;
import com.liveneo.adapter.webservice.client.claim.ImageInfoRequestDto;
import com.liveneo.adapter.webservice.client.claim.OcrSurvey;
import com.liveneo.adapter.webservice.client.claim.Resume;
import com.liveneo.adapter.webservice.client.claim.SetNormalRegisterRequestDto;
import com.liveneo.adapter.webservice.client.claim.SurveyReassignRequestDto;
import com.liveneo.adapter.webservice.client.claim.SurveyReassignType;
import com.liveneo.adapter.webservice.client.claim.UploadOcrInfo;

/**
  * @Description: 调用核心接口
  * @author liveneo-shuqw
  * @date 2016年10月12日 下午5:30:59
  * Copyright: Copyright (c) 2016 
  * Company: 北京朗泰
  * @version 3.0
  */
public class ClaimInterface {
	
    private static DBTableUtil dbTableUtil = (DBTableUtil) SpringConfigTool.getBean("DBTableUtil");
    // 朗泰http
    public static String    HTTPURLCORE = PropertyConfigurer.getValue("HTTPURLCORE");
    // public static String HTTPURLCORE = "http://172.19.5.121:8080/serviceplatform/http/";
    // public static String HTTPURLCORE = "http://sittacyp3.3.mobsurvey.cn/coreservice/http/";
    public static String    HTTPSEDMESSAGE = PropertyConfigurer.getValue("HTTPSEDMESSAGE");

    /**
      * 状态：已调 接口名：SLD07
      * @Title: updateTaskStatus
      * @Description: 查勘任务状态同步调度
      * @param @param request
      * @param @return 设定文件
      * @return resultInfo
      * @throws
     */
    public static ResultInfo updateTaskStatus(TaskStatusRequest taskStatus) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 设置参数
            RequestHead requestHead = getRequestHead("SLD07", "任务状态同步");
            CliamRequest request = new CliamRequest();
            request.setTaskStatus(taskStatus);
            Map<String, Object> parma = new HashMap<String, Object>();
            // 申请改派
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.info("SLD07->logUuid:" + taskStatus.getLogUuid() + "接口任务状态同步[updateTaskStatus]请求参数：\n" + JsonUtils.toJson(parma) + "\n");
            String data = JsonUtils.toJsonWithBase64(parma);
            BaseResponse br = HttpRequestUtil.postJson(HTTPURLCORE + "updateTaskStatus.json", data, "updateTaskStatus:CLD02", BaseResponse.class);
            LogUtils.info("SLD07->logUuid:" + taskStatus.getLogUuid() + "接口任务状态同步[updateTaskStatus]-->案件号：" + taskStatus.getCaseNo() + "返回结果：\n"
                    + JsonUtils.toJson(br) + "\n");
            if ("000".equals(br.getResponseHead().getResultCode())) {
                // 处理任务计费情况
                dbTableUtil.updateCaseInofStateAndBill(taskStatus.getCaseNo());
            }
            resultInfo.setResultCode(br.getResponseHead().getResultCode());
            resultInfo.setResultMsg(br.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("SLD07->logUuid:" + taskStatus.getLogUuid() + "接口任务状态同步[updateTaskStatus]服务器返回异常-->案件号：" + taskStatus.getCaseNo() + "", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("SLD07查勘同步调度接口：任务状态同步未知或处理异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名： CLD04-SLD08 changeTaskStatus 接口标准：1.2b
      * @Description: 收单查勘状态变更同步到调度
      * @param @param request
      * @param @return 设定文件
      * @return resultInfo
      * @throws
     */
    public static ResultInfo changeTaskStatus(ChangeTaskStatus changeTaskStatus) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 设置参数
            CliamRequest request = new CliamRequest();
            request.setChangeTaskStatus(changeTaskStatus);
            RequestHead requestHead = getRequestHead("CLD04", "changeTaskStatus");
            Map<String, Object> parma = new HashMap<String, Object>();
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.info("接口查勘状态变更同步到调度[CLD04----->changeTaskStatus]请求参数：\n" + JsonUtils.toJson(parma));
            String data = JsonUtils.toJsonWithBase64(parma);
            BaseResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "synSdStatusToDispatch.json", data, "changeTaskStatus:CLD04", BaseResponse.class);
            LogUtils.info("接口查勘状态变更同步到调度[CLD04----->changeTaskStatus]返回结果：\n" + JsonUtils.toJson(response));
            // 结果响应
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口查勘状态变更同步到调度[CLD04----->changeTaskStatus]返回异常", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("查勘状态变更同步到调度未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名：SLD09 1.2b
      * @Description: claimCollectTask
      * @param @param loginName
      * @param @param caseNo
      * @param @param clientFlag
      * @param @return 
      * @return ResultInfo  2016-12-07 11:24:00
      * @throws
     */
    public static ResultInfo claimCollectTask(String loginName, String caseNo, String clientFlag) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            CliamRequest request = new CliamRequest();
            ClaimCollectTask claimCollectTask = new ClaimCollectTask();
            claimCollectTask.setCaseNo(caseNo);
            claimCollectTask.setClientFlag(clientFlag);
            claimCollectTask.setLoginName(loginName);
            request.setClaimCollectTask(claimCollectTask);
            RequestHead requestHead = getRequestHead("SLD09", "claimCollectTask");
            Map<String, Object> parma = new HashMap<String, Object>();
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(parma);
            LogUtils.info("接口确认认领案件[SLD09----->claimCollectTask]请求参数：\n" + JsonUtils.toJson(parma));
            BaseResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "claimCollectTask.json", data, "claimCollectTask:SLD09", BaseResponse.class);
            LogUtils.info("接口确认认领案件[SLD09----->claimCollectTask]返回结果：\n" + JsonUtils.toJson(response));
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口确认认领案件[SLD09----->claimCollectTask]返回异常", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("查勘确认认领案件未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title:状态：已调试; 接口名：原：P03 现：SLC01 findEvaluateInfo 1.2b
      * @Description: 定损单信息查询
      * @param @param registNo 报案号
      * @param @param lossId 
      * @return resultInfo 2016-12-07 11:23:00
      * @throws
     */
    public static ResultInfo findEvaluateInfo(String caseNo, String lossId) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            CliamRequest request = new CliamRequest();
            EvaluateInfoRequestDto ev = new EvaluateInfoRequestDto();
            ev.setLossId(lossId);
            ev.setRegistNo(caseNo);
            request.setEvaluateInfo(ev);
            RequestHead requestHead = getRequestHead("SLC01", "findEvaluateInfo");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口定损单信息查询[SLC01----->findEvaluateInfo]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            FindEvaluateInfoResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "findEvaluateInfo.json", data, "findEvaluateInfo:SLC01",
                    FindEvaluateInfoResponse.class);
            // FindEvaluateInfoResponse response =JSON.parseObject(resData, FindEvaluateInfoResponse.class);
            LogUtils.info("接口定损单信息查询[SLC01----->findEvaluateInfo]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 结果封装
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
            if ("000".equals(response.getResponseHead().getResultCode())) {
                resultInfo.setEvaluateInfoResponseDto(response.getBusinessBody().getResponseEvaluateInfo());
            }
        } catch (Exception e) {
            LogUtils.error("接口定损单信息查询[SLC01----->findEvaluateInfo]服务器返回异常：\n", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("定损单信息查询未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 接口名：原P04  现：SLC02 upoadImage 1.2b
      * @Description: 影视资料上传
      * @param @param requestDto 设定文件
      * @return resultInfo 状态：待调试;
      * @throws
     */
    public static ResultInfo upoadImage(String caseNo, List<CliamUploadDto> uploadDtos) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            ImageInfoRequestDto requestDto = new ImageInfoRequestDto();
            requestDto.setRegistNo(caseNo);
            requestDto.setUserCode("0100125015"); // 固定值
            List<Resume> resumeList = new ArrayList<Resume>();
            for (CliamUploadDto cdt : uploadDtos) {
                Resume resume = new Resume();
                resume.setCandidateName(cdt.getImgName());
                resume.setResumeFileType(cdt.getImgType());
                resume.setResume(StringUtil.toByteArray(cdt.getFileStream()));
                resume.setDocType("C002");
                resume.setDocTypePath("CAR101");
                resume.setImageType("0201");
                resume.setLossId("1");
                resumeList.add(resume);
            }
            requestDto.getResume().addAll(resumeList);
            CliamRequest request = new CliamRequest();
            request.setRequestImageInfo(requestDto);
            RequestHead requestHead = getRequestHead("SLC02", "upoadImage");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口影视资料上传[SLC02----->upoadImage]请求参数：\n" + caseNo + "\n");
            UpoadImageResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "upoadImage.json", data, "upoadImage:SLC02", UpoadImageResponse.class);
            LogUtils.info("接口影视资料上传[SLC02----->upoadImage]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 结果封装
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
//            if ("000".equals(response.getResponseHead().getResultCode())) {
//                if (response.getBusinessBody().getErrorImageInfo() != null) {
//                    resultInfo.setErrorImgList(response.getBusinessBody().getErrorImageInfo().getErrImageList());
//                }
//            }
        } catch (Exception e) {
            LogUtils.error("接口影视资料上传[SLC02----->upoadImage]服务器返回异常：\n", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("影视资料上传未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名：P12-SLC03  findCaseInfo 1.2
      * @Description: 案件信息查询
      * @param @param caseNo 设定文件
      * @return resultInfo 2016-12-07 11:22:00
      * @throws
     */
    public static ResultInfo findCaseInfo(String caseNo) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 请求头
            CaseInfo caseInfo = new CaseInfo();
            caseInfo.setRegistNo(caseNo);
            RequestHead requestHead = getRequestHead("SLC03", "findCaseInfo");
            Map<String, Object> param = new HashMap<String, Object>();
            CliamRequest request = new CliamRequest();
            request.setCaseinfo(caseInfo);
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口案件信息查询[SLC03------->findCaseInfo]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            FindCaseInfoResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "findCaseInfo.json", data, "findCaseInfo:P12", FindCaseInfoResponse.class);
            LogUtils.info("接口案件信息查询[SLC03------->findCaseInfo]服务器响应结果：\n" + JsonUtils.toJson(response) + "\n");
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
            if ("000".equals(response.getResponseHead().getResultCode())) {
                resultInfo.setCaseInfo(response.getBusinessBody().getCaseinfo());
            }
        } catch (Exception e) {
            LogUtils.error("接口案件信息查询[SLC03------->findCaseInfo]服务器响应异常", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("案件信息查询未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名：P16-SLC04 synBranchInfo 1.2b
      * @Description: 查询分行信息
      * @param @param syBankId 银行id
      * @param @param standardareaId 收款人开户银行市
      * @return resultInfo 2016-12-07 11:21:00
      * @throws
     */
    public static ResultInfo synBranchInfo(long syBankId, long standardareaId) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 请求参数
            CliamRequest request = new CliamRequest();
            GgBanklocationsDto gBanklocationsDto = new GgBanklocationsDto();
            gBanklocationsDto.setSyBankId(syBankId);
            gBanklocationsDto.setStandardareaId(standardareaId);
            request.setBranchInfo(gBanklocationsDto);
            RequestHead requestHead = getRequestHead("SLC06", "synBranchInfo");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口查询分行信息[SLC06--->synBranchInfo]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            SynBranchInfoResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "synBranchInfo.json", data, "synBranchInfo:P16",
                    SynBranchInfoResponse.class);
            LogUtils.info("接口查询分行信息[SLC06--->synBranchInfo]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 返回结果
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
            if ("000".equals(response.getResponseHead().getResultCode())) {
                resultInfo.setBranchInfo(response.getBusinessBody().getBranchInfo());
            }
        } catch (Exception e) {
            LogUtils.error("接口获取分行信息[SLC06---->synBranchInfo]服务器返回异常", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("获取分行信息未知或网络异常");
        }
        return resultInfo;
    }

    /**
     * @return 
      * @Title: 状态：已调;接口名：P17 现：SLC05 uploadOCRinfo2JY2G 3.3接口标准
      * @Description: 领款人信息和驾驶证行驶证信息
      * @param @param ocrSurvey 
      * 			  type  1:驾驶证信息；2：行驶证信息
    						3：身份证信息；4：银行信息
      * @return  resultInfo 
      * @throws
      */
    public static ResultInfo uploadOCRinfo2JY2G(OcrSurvey ocrSurvey, String type) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            RequestHead requestHead = getRequestHead("SLC05", "uploadOCRinfo2JY2G");
            CliamRequest request = new CliamRequest();
            Map<String, Object> param = new HashMap<String, Object>();
            UploadOcrInfo uploadOcrInfo = new UploadOcrInfo();
            uploadOcrInfo.setOcrSurvey(ocrSurvey);
            uploadOcrInfo.setType(type);
            request.setUploadOcrInfo(uploadOcrInfo);
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口领款人信息和驾驶证行驶证信息[SLC05--->uploadOCRinfo2JY2G]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            UploadOCRinfo2JY2GResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "uploadOCRinfo2JY2G.json", data, "uploadOCRinfo2JY2G:SLC05",
                    UploadOCRinfo2JY2GResponse.class);
            LogUtils.info("接口领款人信息和驾驶证行驶证信息[SLC05--->uploadOCRinfo2JY2G]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 返回结果
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口领款人信息和驾驶证行驶证信息[SLC05--->uploadOCRinfo2JY2G]服务器返回异常：\n", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("领款人信息和驾驶证行驶证信未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名：P19-SLC06 autoCollectDoc 1.2b
      * @Description: 自动单证收集任务
      * @param @param caseNo
      * 			  userCode 理算人员代码
      * @param @return 设定文件
      * @return resultInfo 2016-12-07 11:19:00
      * @throws
     */
    public static ResultInfo autoCollectDoc(String caseNo, String userCode) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 设置参数
            CliamRequest request = new CliamRequest();
            RequestHead requestHead = getRequestHead("SLC06", "自动单证收集任务");
            Map<String, Object> parma = new HashMap<String, Object>();
            CollectDoc collectDoc = new CollectDoc();
            collectDoc.setRegistNo(caseNo);
            collectDoc.setUserCode(userCode);
            request.setCollectDoc(collectDoc);
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.error("接口自动单证收集任务[SLC06------->autoCollectDoc]请求参数：" + JsonUtils.toJson(parma));
            String data = JsonUtils.toJsonWithBase64(parma);
            BaseResponse br = HttpRequestUtil.postJson(HTTPURLCORE + "autoCollectDoc.json", data, "autoCollectDoc:SLC06", BaseResponse.class);
            resultInfo.setResultCode(br.getResponseHead().getResultCode());
            resultInfo.setResultMsg(br.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口自动单证收集任务[SLC06------->autoCollectDoc]服务器返回异常：", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("自动单证收集任务未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * 状态：已调 ; 接口名：P20-SLC07
      * @Title: queryCaseStatus 1.2b接口标准
      * @Description: 案件状态查询服务
      * @param @param caseNo
      * @return resultInfo 2016-12-07 11:00:01 succ
      * @throws
     */
    public static ResultInfo queryCaseStatus(String caseNo) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 设置参数
            CliamRequest request = new CliamRequest();
            QueryCaseStatus queryCaseStatus = new QueryCaseStatus();
            queryCaseStatus.setRegistNo(caseNo);
            request.setQueryCaseStatus(queryCaseStatus);
            RequestHead requestHead = getRequestHead("SLC07", "queryCaseStatus");
            Map<String, Object> parma = new HashMap<String, Object>();
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.error("接口案件状态查询服务[SLC07----->queryCaseStatus]请求参数：" + JsonUtils.toJson(parma));
            String data = JsonUtils.toJsonWithBase64(parma);
            CaseStatusResponse br = HttpRequestUtil.postJson(HTTPURLCORE + "queryCaseStatus.json", data, "queryCaseStatus:SLC07", CaseStatusResponse.class);
            resultInfo.setResultCode(br.getResponseHead().getResultCode());
            resultInfo.setResultMsg(br.getResponseHead().getErrorMessage());
            if ("000".equals(br.getResponseHead().getResultCode())) {
                resultInfo.setCaseStatus(br.getBusinessBody().getResponseQueryCaseStatus().getCaseStatus());
            }
        } catch (Exception e) {
            LogUtils.error("接口案件状态查询服务[SLC07----->queryCaseStatus]服务器返回异常：", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("案件状态查询服务未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * 状态：已调; 接口名：P22-SLC08   接口标准：1.2b
      * @Title: notificationTask
      * @Description: 任务下发时通知核心
      * @param @param caseNo
      * @param @return 设定文件
      * @return resultInfo 2016-12-07 11:04:00 succ
      * @throws
     */
    public static ResultInfo notificationTask(String caseNo, String mobile) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 设置参数
            CliamRequest request = new CliamRequest();
            RequestHead requestHead = getRequestHead("SLC08", "notificationTask");
            NotificationTask nfk = new NotificationTask();
            nfk.setMobile(mobile);
            nfk.setRegistNo(caseNo);
            request.setNotificationTask(nfk);
            Map<String, Object> parma = new HashMap<String, Object>();
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.info("接口任务下发时通知核心[SLC08--->notificationTask]请求参数：" + JsonUtils.toJson(parma) + "\n");
            String data = JsonUtils.toJsonWithBase64(parma);
            BaseResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "notificationTask.json", data, "notificationTask:SLC08", BaseResponse.class);
            LogUtils.info("接口任务下发时通知核心[SLC08--->notificationTask]返回结果：" + JsonUtils.toJson(response) + "\n");
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口任务下发时通知核心[SLC08--->notificationTask]服务器返回异常", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("任务下发时通知核心未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * 状态：已调 接口名：P23 - SLC09 1.2标准
      * @Title: videoCaseEndService
      * @Description: 案件结束收费接口
      * @param @param registNo
      * @param needPay //0-不需要付费；3-B端用户；4-C端用户
      * @param @return 设定文件
      * @return resultInfo 2016-12-07 11:05:00 succ
      * @throws
     */
    public static ResultInfo videoCaseEndService(String registNo, String needPay) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            CliamRequest request = new CliamRequest();
            VideoCaseEnd videoCaseEnd = new VideoCaseEnd();
            videoCaseEnd.setIsNeedPay(needPay);
            videoCaseEnd.setRegistNo(registNo);
            request.setVideoCaseEnd(videoCaseEnd);
            RequestHead requestHead = getRequestHead("SLC09", "videoCaseEndService");
            Map<String, Object> parma = new HashMap<String, Object>();
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.info("接口案件结束收费[SLC09----->videoCaseEndService]请求参数：\n" + JsonUtils.toJson(parma) + "\n");
            String data = JsonUtils.toJsonWithBase64(parma);
            BaseResponse br = HttpRequestUtil.postJson(HTTPURLCORE + "videoCaseEndService.json", data, "videoCaseEndService:SLC09", BaseResponse.class);
            LogUtils.info("接口案件结束收费[SLC09----->videoCaseEndService]返回结果：\n" + JsonUtils.toJson(br) + "\n");
            resultInfo.setResultCode(br.getResponseHead().getResultCode());
            resultInfo.setResultMsg(br.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口案件结束收费[SLC09----->videoCaseEndService]服务器响应异常：", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("案件结束收费未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title:状态：已调 接口名：P05 
      * @Description: confirmEvaluate
      * @param @return 设定文件
      * @return ResultInfo 返回类型
      * @throws
     */
    @Deprecated
    public static ResultInfo confirmEvaluate(String caseNo, String isAgree, String confirmType, String confirmBy, Date confirmDate) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            ConfirmEvaluateDto confirm = new ConfirmEvaluateDto();
            confirm.setRegistNo(caseNo);
            confirm.setIsAgree(isAgree);
            confirm.setConfirmType(confirmType);
            confirm.setConfirmBy(confirmBy);
            confirm.setConfirmDate(confirmDate.getTime());
            RequestHead requestHead = getRequestHead("P05", "confirmEvaluate");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", confirm);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口用户定损结果确认[P05----->confirmEvaluate]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            CliamResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "confirmEvaluate.json", data, "confirmEvaluate:P05", CliamResponse.class);
            LogUtils.info("接口用户定损结果确认[P05----->confirmEvaluate]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 返回结果
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口用户定损结果确认[P05----->confirmEvaluate]服务器返回异常：\n", e);
            // 返回结果
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("用户定损结果确认未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调试 ;接口名：P06
      * @Description: 案件转人工查勘
      * @param @param caseNo
      * @param @param status
      * @param @param userCode
      * @param @param reassignReason
      * @return resultInfo
      * @throws
     */
    @Deprecated
    public static ResultInfo setNormalRegisterService(String caseNo, String status, String userCode, String reassignReason) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            SetNormalRegisterRequestDto setNormal = new SetNormalRegisterRequestDto();
            setNormal.setReassignReason(reassignReason);
            setNormal.setRegisterNo(caseNo);
            setNormal.setStatus(status);
            setNormal.setUserCode(userCode);
            RequestHead requestHead = getRequestHead("P06", "setNormalRegisterService");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", setNormal);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口案件转人工查勘[P06----->setNormalRegisterService]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            CliamResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "setNormalRegisterService.json", data, "setNormalRegisterService:P06",
                    CliamResponse.class);
            LogUtils.info("接口案件转人工查勘[P06----->setNormalRegisterService]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 返回结果
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口案件转人工查勘[P06----->setNormalRegisterService]服务器返回异常：\n", e);
            // 返回结果
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("案件转人工查勘未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title:状态：已调; 接口名：P09 applySurveyReassign
      * @Description: 查勘定损任务改派
      * @param  caseNo 报案号
      * @param  isPay 1：支付，0：不支付
      * @param  reassignTypes  定损改派入参所需信息
      * 		surveyReassignType 1（查勘定损），2（定损）
      * 		lossType 非空，“1”：标的车；”2”：三者车；”3”：物
      * @param  reason 改派原因
      * @param @return 设定文件
      * @return resultInfo
      * @throws
     */
    @Deprecated
    public static ResultInfo applySurveyReassign(String caseNo, String isPay, List<SurveyReassignType> reassignTypes, String reason) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            SurveyReassignRequestDto sd = new SurveyReassignRequestDto();
            sd.setRegistNo(caseNo);
            sd.setIspay(isPay);
            sd.getSurveyReassignTypes().addAll(reassignTypes);
            sd.setReassignReason(reason);
            RequestHead requestHead = getRequestHead("P09", "applySurveyReassign");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", sd);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口查勘定损任务改派[P09----->applySurveyReassign]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            CliamResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "applySurveyReassign.json", data, "applySurveyReassign:P09", CliamResponse.class);
            LogUtils.info("接口查勘定损任务改派[P09----->applySurveyReassign]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 返回结果
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口查勘定损任务改派[P09----->setNormalRegisterService]服务器返回异常：\n", e);
            // 返回结果
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("查勘定损任务改派未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名：P15-CLD02 queryClaim 1.2b
      * @Description: 获取保单出险历史
      * @param @param policyNo 保单号
      * @param @return 
      * @return resultInfo 2016-12-07 11:07:00 succ
      * @throws
     */
    public static ResultInfo queryClaim(String policyNo) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 参数
            CliamRequest request = new CliamRequest();
            QueryClaim queryClaim = new QueryClaim();
            queryClaim.setPolicyNo(policyNo);
            request.setQueryClaim(queryClaim);
            RequestHead requestHead = getRequestHead("CLD02", "queryClaim");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            LogUtils.info("接口获取保单出险历史[CLD02--->queryClaim]请求参数：" + JsonUtils.toJson(param) + "\n");
            String data = JsonUtils.toJsonWithBase64(param);
            ClaimInfoResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "queryClaim.json", data, "queryClaim:CLD02", ClaimInfoResponse.class);
            LogUtils.info("接口获取保单出险历史[CLD02--->queryClaim]返回结果：" + JsonUtils.toJson(response) + "\n");
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
            if ("000".equals(response.getResponseHead().getResultCode())) {
                resultInfo.setClaimInfoList(response.getBusinessBody().getClaimInfoList());
            }
        } catch (Exception e) {
            LogUtils.error("接口获取保单出险历史[CLD02--->queryClaim]服务器返回异常", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("获取保单出险历史未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：未调; 接口名：P18-DLC03 queryVIPService
      * @Description: VIP服务项目查询服务
      * @param @param policyNo
      * @param @param registNo 设定文件
      * @return resultInfo 2016-12-07 11:08:00 succ
      * @throws
     */
    public static ResultInfo queryVIPService(String policyNo, String registNo) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            // 参数
            CliamRequest request = new CliamRequest();
            QueryVIPService queryVIPService = new QueryVIPService();
            queryVIPService.setPolicyNo(policyNo);
            queryVIPService.setRegistNo(registNo);
            request.setQueryVIPService(queryVIPService);
            RequestHead requestHead = getRequestHead("DLC03", "queryVIPService");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", request);
            param.put("requestHead", requestHead);
            LogUtils.info("接口VIP服务项目查询[DLC03--->queryVIPService]请求参数：" + JsonUtils.toJson(param) + "\n");
            String data = JsonUtils.toJsonWithBase64(param);
            VIPServiceResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "queryVIPService.json", data, "queryVIPService:DLC03",
                    VIPServiceResponse.class);
            LogUtils.info("接口VIP服务项目查询[DLC03--->queryVIPService]返回结果：" + JsonUtils.toJson(registNo) + "\n");
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
            if ("000".equals(response.getResponseHead().getResultCode())) {
                resultInfo.setResponseVIPService(response.getBusinessBody().getResponseVIPService());
                ;
            }
        } catch (Exception e) {
            LogUtils.error("接口VIP服务项目查询[DLC03--->queryVIPService]服务器返回异常：", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("VIP服务项目查询未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调;接口名：P10 surveyMembersReassign
      * @Description: 查勘员改派
      * @param @param caseNo
      * @param @param userCode
      * @param @param reason
      * @param @return 设定文件
      * @return resultInfo
      * @throws 废弃接口
     */
    @Deprecated
    public static ResultInfo surveyMembersReassign(String caseNo, String userCode, String reason) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            SurveyReassignRequestDto sd = new SurveyReassignRequestDto();
            sd.setRegistNo(caseNo);
            sd.setUserCode(userCode);
            sd.setReassignReason(reason);
            RequestHead requestHead = getRequestHead("P10", "surveyMembersReassign");
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("businessBody", sd);
            param.put("requestHead", requestHead);
            String data = JsonUtils.toJsonWithBase64(param);
            LogUtils.info("接口查勘员改派[P10----->surveyMembersReassign]请求参数：\n" + JsonUtils.toJson(param) + "\n");
            CliamResponse response = HttpRequestUtil.postJson(HTTPURLCORE + "surveyMembersReassign.json", data, "surveyMembersReassign:P10",
                    CliamResponse.class);
            LogUtils.info("接口查勘员改派[P10----->surveyMembersReassign]返回结果：\n" + JsonUtils.toJson(response) + "\n");
            // 返回结果
            resultInfo.setResultCode(response.getResponseHead().getResultCode());
            resultInfo.setResultMsg(response.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口查勘员改派[P10----->surveyMembersReassign]服务器返回异常：\n", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("查勘员改派未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: 状态：已调; 接口名：SLD10 applySurveyDelegate
      * @Description:查勘定损任务调度 
      * @param @param request 设定文件
      * @return resultInfo 2016-12-07 11:18:00 error
      * @throws
     */
    public static ResultInfo applySurveyDelegate(List<SurveyDelegateRequestDto> delegateRequestDto) {
        ResultInfo resultInfo = new ResultInfo();
        try {
            CliamRequest request = new CliamRequest();
            request.setSurveyDelegate(delegateRequestDto);
            RequestHead requestHead = getRequestHead("SLD10", "查勘定损任务调度 ");
            Map<String, Object> parma = new HashMap<String, Object>();
            parma.put("businessBody", request);
            parma.put("requestHead", requestHead);
            LogUtils.info("接口查勘定损任务调度[SLD10----->applySurveyDelegate]请求参数：\n" + JsonUtils.toJson(parma) + "\n");
            String data = JsonUtils.toJsonWithBase64(parma);
            BaseResponse br = HttpRequestUtil.postJson(HTTPURLCORE + "applySurveyDelegate.json", data, "applySurveyDelegate:SLD01", BaseResponse.class);
            LogUtils.info("接口查勘定损任务调度[SLD10----->applySurveyDelegate]返回结果：\n" + JsonUtils.toJson(br) + "\n");
            resultInfo.setResultCode(br.getResponseHead().getResultCode());
            resultInfo.setResultMsg(br.getResponseHead().getErrorMessage());
        } catch (Exception e) {
            LogUtils.error("接口查勘定损任务调度[SLD10----->applySurveyDelegate]服务器返回异常：\n", e);
            resultInfo.setResultCode("999");
            resultInfo.setResultMsg("查勘定损任务调度未知或网络异常");
        }
        return resultInfo;
    }

    /**
      * @Title: sendMessageInfo
      * @Description: 个推消息
      * @param @param message 设定文件
      * @return void 返回类型
      * @throws
     */
    public static void sendMessageInfo(Message message) {
        try {
            MessageRequest request = new MessageRequest();
            String uuid = UUIDUtils.uuid(); // uuid
            String projectCode = "CK"; // 项目编号
            long curTime = System.currentTimeMillis(); // 时间戳
            String token = Encryption.encryptMD5ToString(projectCode + uuid + curTime).toLowerCase();
            request.setCurTime(String.valueOf(curTime));
            request.setUuid(uuid);
            List<Message> msgList = new ArrayList<Message>();
            msgList.add(message);
            request.setMsgList(msgList);
            request.setToken(token);
            request.setProjectCode(projectCode);
            LogUtils.info("接口个推消息推送[BP01----->pushMessage]请求参数：\n" + JsonUtils.toJson(request) + "\n");
            String data = JsonUtils.toJsonWithBase64(request);
            AppMessage br = HttpRequestUtil.getJson(HTTPSEDMESSAGE, data.replace("+", "%2B"), "pushMessage:BP01", AppMessage.class);
            LogUtils.info("接口个推消息推送[BP01----->pushMessage]返回结果：\n" + JsonUtils.toJson(br) + "\n");
        } catch (Exception e) {
            LogUtils.error("接口个推消息推送[BP01----->pushMessage]服务器返回异常：\n", e);
        }
    }

    /**
      * @Title: getRequestHead
      * @Description: 封装头
      * @param @param faceCode
      * @param @param faceName
      * @param @return 设定文件
      * @return RequestHead 返回类型
      * @throws
     */
    public static RequestHead getRequestHead(String faceCode, String faceName) {
        RequestHead requestHead = new RequestHead();
        requestHead.setInterfaceCode(faceCode);
        requestHead.setInterfaceName(faceName);
        requestHead.setServiceCode("S");
        requestHead.setServiceName("查勘平台");
        requestHead.setCompanyCode("TIANANCORE");
        String seqNo = String.valueOf(System.currentTimeMillis());
        requestHead.setSeqNo(seqNo);
        String mac = Encryption.encryptMD5ToString("S" + faceCode + seqNo).toLowerCase();
        requestHead.setSignatureCode(mac);
        return requestHead;
    }

    /**
      * @Title: getResponseHead
      * @Description: 响应head
      * @param @param faceCode
      * @param @param faceName
      * @param @return 设定文件
      * @return ResponseHead 返回类型
      * @throws
     */
    public static ResponseHead getResponseHead(String faceCode, String faceName) {
        ResponseHead responseHead = new ResponseHead();
        responseHead.setInterfaceCode(faceCode);
        responseHead.setInterfaceName(faceName);
        responseHead.setServiceCode("S");
        responseHead.setServiceName("查勘平台");
        String seqNo = String.valueOf(System.currentTimeMillis());
        responseHead.setSeqNo(seqNo);
        return responseHead;
    }
}
